﻿@model IEnumerable<ServerManager.Models.Server>

@{
    ViewData["Title"] = "Index";
}

<div style="height:40px;line-height:40px;margin-top:10px;">
    <div style="float:left;font-size:2em;">服务器列表</div>
    <div style="float:right"><a class="btn btn-info" asp-action="CreateOrUpdate">新建</a></div>
</div>
<hr />
<table class="table">
    <thead>
        <tr>
            <th></th>
            <th>
                @Html.DisplayNameFor(model => model.Position)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Brand)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Cpu)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Memory)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.HardDisk)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Remark)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Apps)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.IpAddresses)
            </th>
            <th></th>
        </tr>
    </thead>
    <tbody>
        @{ int i = 1; }
        @foreach (var item in Model)
        {
            string c = string.Empty;
            string status = string.Empty;
            if (item.Status == 0)
            {
                c = "NotAvailable";
                status = "不可用";
            }
            else if (item.Status == 1)
            {
                c = "Idle";
                status = "空闲";
            }
            else if (item.Status == 2)
            {
                c = "Used";
                status = "占用";
            }
        <tr class=@c>
            <td>@(i++)</td>
            <td>
                @Html.DisplayFor(modelItem => item.Position)
            </td>
            <td>
                <a asp-action="Details" asp-route-id="@item.Id">
                    @Html.DisplayFor(modelItem => item.Brand)
                </a>
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Cpu)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Memory)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.HardDisk)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Remark)
            </td>
            <td>
                @{
                    foreach (var app in item.Apps)
                    {
                        <span>@app.Name <br /></span>
                    }
                }
            </td>
            <td>
                @{
                    foreach (var ip in item.IpAddresses)
                    {
                        <span>@ip.Ip <br /></span>
                    }
                }
            </td>
            <td>
                <a class="btn btn-success" asp-action="CreateOrUpdate" asp-route-id="@item.Id">编辑</a>
            </td>
        </tr>
        }
    </tbody>
</table>
